package com.example.chapter3_1.mapper;


import com.example.chapter3_1.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserDao {

    @Results(id = "userMap",value ={
            @Result(id = true,property = "username",column = "username"),
            @Result(property = "password",column = "password"),
            @Result(property = "sex",column = "sex"),
            @Result(property = "id",column = "id")
    })
    @Select("select * from user where username = #{username} and password = #{password} ")
    User getUserByName( String username,String password);
//    User getUserByName(@Param("userName") String name,String password);

//    @Insert("insert into user(username,password,sex) values (#{username},#{password},#{sex})")
//    int creatUser(User user);

    @Select("select count(1) from user where username = #{username}")
    int findUserByName(String username);
    @Insert("insert into user(username,password,sex) values (#{username},#{password},#{sex})")
    int creatUser(User user);
}
